package tcln.sors.model.core.criteria;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;


/**
 * Information necessary for selection methods from client-side to specify which property should be sorted.
 * 
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public final class SortInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    private Map<String, SortOrder> sortInfoMap = new LinkedHashMap<String, SortOrder>(11);

    /**
     * Creates new {@link SortInfo} instance.
     * 
     * @return New {@link SortInfo} instance.
     */
    public static SortInfo create() {
        return new SortInfo();
    }

    SortInfo() {
        // to hide
    }

    /**
     * Adds new sorting property with sort order.
     * 
     * @param property
     * @param order
     * @return Current instance.
     */
    public SortInfo add(String property, SortOrder order) {
        sortInfoMap.put(property, order);
        return this;
    }

    /**
     * Returns current sorting information.
     * 
     * @return A {@link Map} of all sorting information.
     */
    public Map<String, SortOrder> getSortingInfo() {
        return sortInfoMap;
    }
}
